﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SmallERP.FenPian.Presenter;


namespace SmallERP.FenPian
{
    public partial class UCGrid : UserControl
    {
        /// <summary>
        /// 分片格子信息类
        /// </summary>
        public UCGrid()
        {
            InitializeComponent();
        }

        private UCGridStatus _gridStatus;
        public UCGridStatus GridStatus { set { _gridStatus = value; SetBackColorByStatus(); } get { return _gridStatus; } }

        private void SetBackColorByStatus()
        {
            //if (_gridStatus != null)
            //{
                switch (_gridStatus)
                {
                    case UCGridStatus.TimeOut:
                        this.BackColor = Color.Red;
                        break;
                    case UCGridStatus.Priority:
                        break;
                    case UCGridStatus.OutOver:
                        this.BackColor = Color.Green;
                        break;
                    case UCGridStatus.Selected:
                        this.BackColor = Color.Khaki;
                        break;
                    case UCGridStatus.Normal:
                        BackColor = Color.White;
                        break;
                }
            //}
        }



        //格子ID
        public int GridId { get; set; }
        //格子名称
        public string GridName
        {
            get { return this.labGridName.Text; }
            set { this.labGridName.Text = value; }
        }

        //产品名称
        public string OrderProductName
        {
            set { this.labProductName.Text = value; }
        }

        //总数
        public int PicCout
        {
            set { this.labCout.Text = value.ToString(); }
        }
        //当前数量
        public int CurPicCount
        {
            set { this.labCurr.Text = value.ToString(); }
            get
            {
                if (string.IsNullOrEmpty(this.labCurr.Text))
                {
                    return 0;
                }
                else
                {
                    try
                    {
                        return Convert.ToInt32(this.labCurr.Text);
                    }
                    catch (Exception)
                    {
                        return 0;
                       
                    }
                }
            }
        }        
    }
 
}
